package com.zpxt.zpxt.dao;

import com.zpxt.zpxt.entity.Position;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @Author:hjx
 * @Description:
 * @Date: Created in 19:48 2018/4/13
 * @Modified By:
 */
public interface PositionRepository extends JpaRepository<Position, Long> {
    List<Position> findByCompanyId(Long companyId);
    Page<Position> findAll(Pageable pageable);
    @Query(value =
            "SELECT\n" +
            "	* \n" +
            "FROM\n" +
            "	position \n" +
            "WHERE\n" +
            "	NAME LIKE CONCAT('%',?1,'%')",
            countQuery = "SELECT count(*) FROM position WHERE NAME LIKE CONCAT('%',?1,'%')",
            nativeQuery = true)
    Page<Position> findAllLike(String name, Pageable pageable);
}
